package com.lcf.system.controller;


import com.lcf.framework.vo.PageVO;
import com.lcf.system.dto.UserOrderDTO;
import com.lcf.system.query.UserOrderPageQuery;
import com.lcf.system.service.UserOrderService;
import com.lcf.system.vo.UserOrderVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 订单(UserOrder)表控制层
 *
 * @author lcf
 * @since 2025-04-24 21:14:33
 */
@Tag(name = "订单")
@RestController
@RequestMapping("userOrder")
public class UserOrderController {
    @Resource
    private UserOrderService userOrderService;

    /**
     * 下单
     */
    @Operation(summary = "下单")
    @PostMapping
    public boolean insert(@RequestBody @Validated UserOrderDTO dto) {
        return userOrderService.insert(dto);
    }

    /**
     * 付款
     */
    @Operation(summary = "付款")
    @PostMapping("pay/{orderId}")
    public boolean pay(@PathVariable @Schema(description = "订单id") Long orderId) {
        return userOrderService.pay(orderId);
    }

    /**
     * 发货
     */
    @Operation(summary = "发货")
    @PostMapping("deliver/{orderId}")
    public boolean deliver(@PathVariable @Schema(description = "订单id") Long orderId) {
        return userOrderService.deliver(orderId);
    }

    /**
     * 确认收货
     */
    @Operation(summary = "确认收货")
    @PostMapping("confirm/{orderId}")
    public boolean confirm(@PathVariable @Schema(description = "订单id") Long orderId) {
        return userOrderService.confirm(orderId);
    }

    /**
     * 退款
     */
    @Operation(summary = "退款")
    @PostMapping("refund/{orderId}")
    public boolean refund(@PathVariable @Schema(description = "订单id") Long orderId) {
        return userOrderService.refund(orderId);
    }

    /**
     * 订单分页
     */
    @Operation(summary = "订单分页")
    @GetMapping("page")
    public PageVO<UserOrderVO> page(UserOrderPageQuery query) {
        return userOrderService.page(query);
    }

    /**
     * 订单详情
     */
    @Operation(summary = "订单详情")
    @GetMapping("{id}")
    public UserOrderVO detail(@PathVariable long id) {
        return userOrderService.detail(id);
    }
    /**
     * 所有订单分页
     */
    @Operation(summary = "所有订单分页")
    @GetMapping("all")
    public PageVO<UserOrderVO> pageAll(UserOrderPageQuery query) {
        return userOrderService.pageAll(query);
    }

}

